package com.wl2o2o.lanqiao.xzfourteen;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


/** 
* @author : WLei224
* @date ：2023年3月18日 上午10:55:39 
* 
*/
public class 求和 {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		long sum = 0; 
		long cnt = 0;
		long ans = 0;
		int[] num = new int[n+1];
		String[] strings = in.readLine().split(" ");
		//数列前n前n项求和，储存到sum中
		for(int j = 0; j < n; j++) {
			sum += Integer.parseInt(strings[j]);
		}
		//
		for(int i = 0; i < n; i++) {
			num[i] = Integer.parseInt(strings[i]);
			cnt += num[i];
			ans += num[i] * (sum - cnt);
		}
		System.out.println(ans);
	}

}
